package com.eian.boot.common.id.model;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * ID号段实体
 *
 * @author alex.meng
 */
@Data
@Table("id_segment")
public class IdSegmentEntity {

    /**
     * 业务类型标识
     */
    @Id
    @Column("biz_type")
    private String bizType;

    /**
     * 当前已分配的最大ID
     */
    @Column("max_id")
    private Long maxId;

    /**
     * 每次获取的步长
     */
    @Column("step")
    private Integer step;

    /**
     * 业务描述
     */
    @Column("description")
    private String description;

    /**
     * 版本号（乐观锁）
     */
    @Column(value = "version", version = true)
    private Integer version;

    /**
     * 创建时间
     */
    @Column(value = "created_at", onInsertValue = "now()")
    private LocalDateTime createdAt;

    /**
     * 修改时间
     */
    @Column(value = "modified_at", onInsertValue = "now()", onUpdateValue = "now()")
    private LocalDateTime modifiedAt;
}

